megatron_path=/apdcephfs_qy3/share_976139/users/adrenzhou/nlp_workdir/Megatron-LM
load_path=$1
latest_num=`cat $1/latest_checkpointed_iteration.txt`
save_path=$1/hf_${latest_num}
#save_path=hunyuan-7b-back-hf
#orig_hf_path=/apdcephfs_qy3/share_976139/users/adrenzhou/nlp_workdir/pretrained_models/thudm/chatglm3-6b-128k
# orig_hf_path="/apdcephfs_qy3/share_976139/users/adrenzhou/nlp_workdir/pretrained_models/Qwen/Qwen2-Audio-7B-Instruct"
# orig_hf_path="Qwen-audio-whisper-tiny-qwen-0.5B"
orig_hf_path="penguins_llm_conformer_hf"
mkdir -p $save_path
#find $orig_hf_path -type f ! -name 'model*' -exec cp {} $save_path/ \;
cp $orig_hf_path/* $save_path/

set -e
python tools/penguins_checkpoint_conversion.py \
--convert_checkpoint_from_megatron_to_transformers \
--load_path $load_path \
--save_path $save_path \
--target_params_dtype "bf16" \
--make_vocab_size_divisible_by 1 \
--print-checkpoint-structure \
--megatron-path $megatron_path \
# --tokenizer-type HFTokenizer \
# --tokenizer-model $orig_hf_path


#python comp_ckp.py 
